package com.voute.View.Adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.voute.Base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liucxu on 2017/3/7.
 */

public class NewHotCommentsFragmentAdapter extends FragmentPagerAdapter {

    private List<String> mTitles = new ArrayList<>();
    private List<BaseFragment> mFragments = new ArrayList<>();

    public NewHotCommentsFragmentAdapter(FragmentManager fm, List<String> titles, List<BaseFragment> fragments) {
        super(fm);
        if (titles != null) {
            mTitles.clear();
            mTitles.addAll(titles);
        }
        if (fragments != null) {
            mFragments.clear();
            mFragments.addAll(fragments);
        }
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mTitles.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position);
    }
}
